<?php
namespace plugin\ky_black\app\admin\controller;

use support\Request;
use support\Response;

class BaseController
{
    /**
     * 成功返回
     * @param array $data
     * @param string $msg
     * @return Response
     */
    protected function success($data = [], $msg = 'success'): Response
    {
        return json([
            'code' => 0,
            'msg' => $msg,
            'data' => $data
        ]);
    }

    /**
     * 失败返回
     * @param string $msg
     * @param array $data
     * @return Response
     */
    protected function error($msg = 'error', $data = []): Response
    {
        return json([
            'code' => 1,
            'msg' => $msg,
            'data' => $data
        ]);
    }
} 